from django.shortcuts import render
from App.models import Articles, Friendlink


# Create your views here.
def home(request):
    tmp = "<h1>Hello</h1>"
    # 查询推荐文章，取前10
    recommand_Articles = Articles.objects.filter(isrecommend=True)[:10]
    # 原创文章查询
    creators = Articles.objects.filter(iscreator=True)[:5]
    links = Friendlink.objects.all()
    return render(request, 'home.html',locals())


def article_lsit(request):
    return render(request,"list.html")


def login(request):
    return render(request,"login.html")


def register(request):
    return render(request,"register.html")


def article_detail(request,tid):
    print(tid)
    # get根据主键查询 pk代表主键
    article = Articles.objects.get(pk=tid)
    print(article)
    return render(request,"content.html",locals())